home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 1886 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.3 KB

  1. Path: atglab.bls.com!Alun.Champion
  2. From: Alun.Champion@bridge.bst.bls.com (Alun Champion)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: What should be returned?
  5. Date: 17 Jan 1996 17:10:38 GMT
  6. Organization: Computer People Inc.
  7. Message-ID: <ALUN.CHAMPION.96Jan17121038@g7240065.bridge.bst.bls.com>
  8. References: <4dj8pv$cjd@eng_ser1.erg.cuhk.hk>
  9. NNTP-Posting-Host: bstfirewall.bst.bls.com
  10. In-reply-to: phsung@cs.cuhk.hk's message of 17 Jan 1996 16:40:31 GMT
  11.  
  12. In article <4dj8pv$cjd@eng_ser1.erg.cuhk.hk> phsung@cs.cuhk.hk (the CAReLess boy) writes:
  13.  
  14. : Hi, all,
  15.  
  16. :  It's said that the function main must return an integer value
  17. : but I just don't know what value should be returned.  Also, if I quit
  18. : main by exit(), what's the use of the return value?
  19.  
  20. The integer value is dependent on the host environment. This being the case
  21. the standard requires two macros to be defined in stdlib.h, namely
  22. EXIT_SUCCESS and EXIT_FAILURE, to provide the correct return values from
  23. you program.
  24.  
  25. A return from main() is equivalent to an exit(). Personally I prefer the
  26. return, an explicit call to exit(), to me, implies something has gone
  27. wrong in the program from which it can't recover and has no neat means of
  28. completing the program so must call exit().
  29.  
  30. Regards
  31.  
  32.    -A.
  33. -- 
  34. | A.Champion                |
  35.